import React, { useRef } from 'react'
import Child from './Child'

// 获取 类组件实例

export default function App() {
  // #1
  const childRef = useRef(null)

  const handleClick = () => {
    // #3
    // childRef.current => 类组件实例 => 意味类组件有的，实例都可以用
    // console.log(childRef.current)
    childRef.current.changeCount(2)
  }
  return (
    <div>
      App
      <button onClick={handleClick}>测试</button>
      <hr />
      {/* #2 */}
      <Child ref={childRef} />
    </div>
  )
}
